package model

type PostType struct {
	Ip     uint64 `gorm:"primary_key;auto_increment"`
	IpName string `gorm:"column:ipname;not null" json:"ipname" binding:"required" form:"ipname"`
	//关联字段
	Posts []Post `gorm:"many2many:post_type_map" binding:"-"`
}

type PostTypeMap struct {
	Pid uint64 `gorm:"primaryKey" json:"post_pid"`
	Ip  uint64 `gorm:"primaryKey" json:"post_type_ip"`
}

// 通过类型找post
func (a *PostType) GetPostByType() error {
	return DB.Self.Preload("Posts").First(&a).Error
}
